home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / plotting / contour / contour.lha / Contour / mkdata.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-28  |  659 b   |  29 lines

  1. /*** Print out values in countour format ***/
  2.  
  3. #include <math.h>
  4.  
  5. main()
  6. {
  7.     double xmin = 0.0;
  8.     double xmax = 1.0;
  9.     double ymin = 0.0;
  10.     double ymax = 1.0;
  11.     double dx, dy, x, y, z;
  12.     int    i, j, nx=150, ny=150;
  13.  
  14.     /* print out header first */
  15.     printf("%10.5f %10.5f %10.5f %10.5f\n",xmin,xmax,ymin,ymax);
  16.     printf("%10.5f %10.5f\n",(double)nx,(double)ny);
  17.  
  18.     dx = (xmax-xmin)/(double)(nx-1);
  19.     dy = (ymax-ymin)/(double)(ny-1);
  20.     /* calculate and print out z value */
  21.     for (i=0; i<nx; i++) 
  22.     for (j=0; j<ny; j++)  {
  23.       x = xmin + i*dx;
  24.       y = ymin + j*dy;
  25.       z = sqrt(x*x + y*y);
  26.       printf("%10.5f\n",z);
  27.    }
  28. }
  29.